package org.example;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.*;
import org.example.pojo.User;

import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.CopyOnWriteArraySet;

/**
 * Hello world!
 *
 */
public class App {
    public static void main( String[] args ) throws IOException {
        // 加载配置，创建 sqlSessionFactory
        String resource = "MyBatis-config.xml";
        InputStream inputStream = Resources.getResourceAsStream(resource);
        SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);
        // 创建 sqlSession
        SqlSession sqlSession = sqlSessionFactory.openSession();
        // 执行sql
        List<User> objects = sqlSession.selectList("org.example.mapper.UserMapper.getUserList");
        objects.forEach(System.out::println);
    }
}
